#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 25 09:34:50 2022

@author: liqingsimac
"""

###############################################
##行列式的几何意义
import numpy as np
import matplotlib.pyplot as plt

O=np.array([0,0])
A=np.array([3,1])
B=np.array([1,4])
C=A+B
D=np.array([0,B[1]-B[0]*A[1]/A[0]])
E=A+D

fig=plt.figure()
ax=fig.add_subplot(111)

ax.plot( [O[0],A[0]], [O[1],A[1]], 'bo-' )
ax.plot( [O[0],B[0]], [O[1],B[1]], 'bo-' )
ax.plot( [A[0],C[0]], [A[1],C[1]], 'bo-' )
ax.plot( [B[0],C[0]], [B[1],C[1]], 'bo-' )
ax.plot( [B[0],D[0]], [B[1],D[1]], 'ro-' )
ax.plot( [A[0],E[0]], [A[1],E[1]], 'ro-' )

ax.annotate('A',xy=(3.1,0.8))
ax.annotate('B',xy=(B[0]+0,B[1]+0.3))
ax.annotate('C',xy=(C[0]+0,C[1]+0.3))
ax.annotate('D',xy=(D[0]+0.1,D[1]+0.3))
ax.annotate('E',xy=(E[0]+0,E[1]+0.3))
ax.annotate('O',xy=(O[0]-0.2,O[1]-0.4))

ax.hlines(y=0,xmin=-1,xmax=5)
ax.vlines(x=0,ymin=-1,ymax=6)

ax.set_xlabel('x')
ax.set_ylabel('y')

#fig.savefig('.png')